package com.bRoom.controller.front;

import com.bRoom.common.ServerResponse;
import com.bRoom.pojo.Room;
import com.bRoom.service.IRoomService;
import com.bRoom.vo.RoomDetailVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("front/room")
public class IRoomController {

    @Autowired
    private IRoomService iRoomService;

    @RequestMapping("roomList.do")
    @ResponseBody
    public ServerResponse<PageInfo> frontRoomList(@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,@RequestParam(value = "pageSize",defaultValue = "5") int pageSize){
            return iRoomService.roomList(pageNum,pageSize);
    }

    @RequestMapping("front_roomDetail.do")
    @ResponseBody
    public ServerResponse<RoomDetailVo> frontRoomDetail(Integer roomId){
           return iRoomService.roomDetail(roomId);
    }


    @RequestMapping("front_searchRoom.do")
    @ResponseBody
    public ServerResponse  frontSearchRoom(String roomName,@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,@RequestParam(value = "pageSize",defaultValue = "5") int pageSize){
        return iRoomService.searchRoom(roomName,pageNum,pageSize);
    }
}
